package Utils;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.jdbc.core.JdbcTemplate;

public class JdbcTemplateUtils {
    public static final String username = "root";
    public static final String password = "123456";
    public static final String jdbcUrl = "jdbc:mysql://localhost:3306/students?serverTimezone=GMT%2B8&useUnicode=true&characterEncoding=utf-8";
    public static final String driverName = "com.mysql.cj.jdbc.Driver";
    public static JdbcTemplate getJdbcTemplate(){
        DruidDataSource dataSource= new DruidDataSource();
        dataSource.setUsername(username);
        dataSource.setPassword(password);
        dataSource.setUrl(jdbcUrl);
        dataSource.setDriverClassName(driverName);
        JdbcTemplate jdbcTemplate=new JdbcTemplate();
        jdbcTemplate.setDataSource(dataSource);
        return jdbcTemplate;
    }
}
